<template>
  <div class="admin_main">
    <div class="admin_left">
      <!--      标题-->
      <div class="title">健康管理与咨询系统后台</div>
      <!--      菜单-->
      <el-menu
          :default-active="$route.path"
          class="admin_menu"
          @select="toPages"
      >
<!--        <el-menu-item index="/health/admin/homePage">-->
<!--          <div class="menu_text">-->
<!--            <el-icon class="margB">-->
<!--              <House/>-->
<!--            </el-icon>-->
<!--            <span>主页</span>-->
<!--          </div>-->
<!--        </el-menu-item>-->
        <el-menu-item index="/health/admin/userManage">
          <div class="menu_text">
            <el-icon class="margB">
              <Reading/>
            </el-icon>
            <span>用户管理</span>
          </div>
        </el-menu-item>
        <el-menu-item index="/health/admin/articleManage">
          <div class="menu_text">
            <el-icon class="margB">
              <Reading/>
            </el-icon>
            <span>文章管理</span>
          </div>
        </el-menu-item>
        <el-menu-item index="/health/admin/commentManage">
          <div class="menu_text">
            <el-icon class="margB">
              <ChatDotSquare/>
            </el-icon>
            <span>评论管理</span>
          </div>
        </el-menu-item>
        <el-menu-item index="/health/admin/modelManage">
          <div class="menu_text">
            <el-icon class="margB">
              <PieChart/>
            </el-icon>
            <span>模型管理</span>
          </div>
        </el-menu-item>
        <el-menu-item index="/health/admin/noticeManage">
          <div class="menu_text">
            <el-icon class="margB">
              <ChatDotSquare/>
            </el-icon>
            <span>公告通知管理</span>
          </div>
        </el-menu-item>
      </el-menu>
    </div>
    <div class="admin_right">
      <router-view :key="$route.fullPath"></router-view>
    </div>
  </div>
</template>
<script setup>
import router from "@/router/index.js";
import {ChatDotSquare, House, PieChart, Reading, Setting} from "@element-plus/icons-vue";
import {onMounted} from "vue";
import {loginAuth} from "@/tool/commonFun.js";
import {authAdminApi} from "@/api/login.js";

onMounted(()=>{
  if(loginAuth()===0){
    router.push("/login")
  }
  authAdminApi().then(res=>{
    if(!res.data){
      router.push("/login")
    }
  })
})
function toPages(index) {
  router.push(index)
}
</script>

<style scoped>
.admin_main {
  width: 100%;
  height: calc(100vh - 71px);
  display: flex;
  justify-content: center;
}

.admin_left {
  height: 100%;
  width: 15%;
}

.admin_right {
  height: 100%;
  width: 85%;
}

.title {
  width: 100%;
  text-align: center;
  font-size: 22px;
  height: 50px;
}

.admin_menu {
  height: 100%;
}

.menu_text {
  width: 100%;
  font-size: 16px;
  margin-left: 30px;

}

.margB {
  margin-bottom: 4px;
}
</style>